import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

const originalPush = VueRouter.prototype.push
 
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const Discover  = () => import('views/discover/Discover')
const Broadcast  = () => import('views/broadcast/Broadcast')
const Friend  = () => import('views/friend/Friend')
const Video  = () => import('views/video/Video')
const Private  = () => import('views/private/Private')
const playListDetail  = () => import('views/playlistdetail/playListDetail')
const Profile  = () => import('views/profile/Profile')
const EditProfile  = () => import('views/profile/EditProfile')
const DongTai  = () => import('views/profile/DongTai')
const Follows  = () => import('views/profile/Follows')
const perfectComment  = () => import('components/content/perfectComment')
const Recommend  = () => import('views/discover/childroute/recommend/Recommend')
const Playlist  = () => import('views/discover/childroute/playlist/Playlist')
const Playlists  = () => import('views/discover/childroute/playlist/childComps/Playlists')
const BestPlaylist  = () => import('views/discover/childroute/playlist/childComps/BestPlaylist')
const List  = () => import('views/discover/childroute/list/List')
const Singer  = () => import('views/discover/childroute/singer/Singer')
const Latestmusic  = () => import('views/discover/childroute/latestmusic/Latestmusic')
const NewSong  = () => import('views/discover/childroute/latestmusic/childComps/newSong')
const NewAlbum  = () => import('views/discover/childroute/latestmusic/childComps/newAlbum')
const recentPlay  = () => import('views/recentplay/recentPlay')
Vue.use(VueRouter)

const routes = [
    {
      path:'/',
      redirect:'/discover',
    },
    {
      path:'/discover',
      component:Discover,
      redirect:'/discover/recommend',
      children:[
        {
          path:'/discover/recommend',
          component:Recommend
        },
        {
          path:'/discover/playlist',
          component:Playlist,
          redirect:'/discover/playlist/playlists',
          children:[
            {
              path:'/discover/playlist/playlists',
              component:Playlists
            },
            {
              path:'/discover/playlist/bestplaylist/:id',
              component:BestPlaylist
            }
          ]
        },
        {
          path:'/discover/list',
          component:List
        },
        {
          path:'/discover/singer',
          component:Singer
        },
        {
          path:'/discover/latestmusic',
          component:Latestmusic,
          redirect:'/discover/latestmusic/newsong',
          children:[
            {
              path:'/discover/latestmusic/newsong',
              component:NewSong
            },
            {
              path:'/discover/latestmusic/newalbum',
              component:NewAlbum
            }
          ]
        },
      ]
    },
    {
      path:'/broadcast',
      component:Broadcast
    },
    {
      path:'/friend',
      component:Friend
    },
    {
      path:'/video',
      component:Video
    },
    {
      path:'/private',
      component:Private
    },
    {
      path:'/playlistdetail/:id/:type',
      component:playListDetail,
    },
    {
      path:'/perfectcomment/:id/:type',
      component:perfectComment
    },
    {
      path:'/profile/:id',
      component:Profile
    },
    {
      path:'/editprofile',
      component:EditProfile
    },
    {
      path:'/dongtai/:id/:title',
      component:DongTai
    },
    {
      path:'/follows/:id/:title/:num',
      component:Follows
    },
    {
      path:'/recentplay',
      component:recentPlay
    }
]

const router = new VueRouter({
  routes
})

export default router
